<template>
	<view>
		<view class="input-box">
			<view class="input-box-real flex">
				<u--input v-model="money" border="none"  placeholder="输入提现金额">
				</u--input>
			</view>
			<view class="available flex">
				<text style="color: #00CE9B;" class="u-font-28">可提现金额 ¥{{usemoney}}手续费{{percent}}%</text>
				<text class="u-font-bold u-font-28" @click="$goTo('pages_my/txdetail/txdetail')" >提现明细</text>
			</view>
		</view>
		<view style="padding: 30rpx;">
			<text class="u-font-bold u-font-32">提现渠道</text>
			<view class="pay_type">
				<view class="item" @click="cpayType">
					<view class="l" >
						<image class="img" src="/static/index/zfb.png" mode=""></image>
						<text>支付宝</text>
					</view>
					<view class="flex-cneter"  v-if="info.alipay" >
						<image v-if="payType===0" class="selectImg" src="/static/selected.png" mode=""></image>
						<image v-else  class="selectImg" src="/static/index/select.png" mode=""></image>
						<view class="u-m-l-30" @click.stop="$goTo('/pages_my/bindzfb/bindzfb')"  style="color: #00CE9B;">修改</view>
					</view>
					<view  class="bd" v-if="!info.alipay" @click.stop="$goTo('/pages_my/bindzfb/bindzfb')">
						绑定账户
					</view>
				</view>
				<view class="item" @click="cpayType">
					<view class="l" >
						<image class="img" src="/static/index/wx.png" mode=""></image>
						<text>微信</text>
					</view>
					<view class="flex-cneter"  v-if="info.wechat_image" >
						<image v-if="payType===1" class="selectImg" src="/static/selected.png" mode=""></image>
						<image v-else   class="selectImg" src="/static/index/select.png" mode=""></image>
						<view class="u-m-l-30" @click.stop="$goTo('/pages_my/bindwx/bindwx')" style="color: #00CE9B;">修改</view>
					</view>
					<view  class="bd" v-if="!info.wechat_image" @click.stop="$goTo('/pages_my/bindwx/bindwx')">
						绑定账户
					</view>
				</view>
			</view>
		</view>
		<view class="submit-btn" @click="withdraw">
			确认提现
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money:'',
				info:'',
				payType:'',
				usemoney:'',
				percent:''
			};
		},
		onShow() {
			this.init()
			this.initwithdraw()
		},
		methods:{
			
			cpayType(){
				if(this.payType == 1){
					this.payType =0
				}else{
					this.payType =1
				}
				
			},
			init(){
				this.$api.post('/updateuserpay',{}).then(res=>{
					
					this.info = res.data
				})
			},
			initwithdraw(){
				this.$api.post('/withdraw',{}).then(res=>{
					
					this.usemoney = res.data.money
					this.percent = res.data.percent
				})
			},
			withdraw(){
				if(!this.money){
					this.$toast('请输入提现金额')
					return
				}
				if(this.payType === ''){
					this.$toast('请选择提现方式')
					return
				}
				this.$api.post('/withdraw',{num:this.money,type:this.payType,types:"withdraw"}).then(res=>{
					this.$toast(res.msg)
					this.init()
				})
			},
		}
	}
</script>

<style lang="scss">
.input-box {
		width: 90vw;
		margin: 50rpx auto;
		border-radius: 30rpx;
		background-color: #FBFBFE;
		.input-box-real{
			background-color: #fff;
			border-radius: 30rpx;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 50rpx;
		}
		.available{
			padding: 40rpx 30rpx;
			align-items: center;
			justify-content: space-between;
		}
	}
	.pay_type{
		.item{
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 686rpx;
			height: 140rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 52rpx;
			box-sizing: border-box;
			margin: 30rpx auto 0;
			.l{
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #333333;
				.img{
					width: 42rpx;
					height: 38rpx;
					margin-right: 20rpx;
				}
			}
			.selectImg{
				width: 32rpx;
				height: 32rpx;
			}
		}
		.bd{
			border-radius: 30rpx;
			border: 1rpx solid $uni-primary;
			width: 150rpx;
			height: 50rpx;
			text-align: center;
			line-height: 50rpx;
			color: $uni-primary;
		}
	}
	
</style>
